#include <iostream>
#include <fstream>
#include <string>
#include "bundle.h"
using namespace std;

int main(int args, char *argv[2])
{
    string pre_filename = argv[1];
    string pack_name = argv[2];
    cout<<pre_filename<<endl<<pack_name<<endl;

    ifstream ifs;
    ifs.open(pre_filename, std::ios::binary);
    ifs.seekg(0, std::ios::end);
    size_t size = ifs.tellg(); // 获取文件指针偏移量
    ifs.seekg(0, std::ios::beg);

    string body;
    body.resize(size);

    ifs.read(&body[0], size); // 将原始文件的内容给到body
    ifs.close();

    string packed = bundle::pack(bundle::LZIP, body); // 以LZIP的方式压缩

    // 将压缩文件写入指定文件
    ofstream ofs;
    ofs.open(pack_name, std::ios::binary);
    ofs.write(packed.c_str(), packed.size());

    ofs.close();
    return 0;
}
